#include <elasticlient/client.h>
#include <cpr/cpr.h>
#include <iostream>

int main() 
{
    // 1. 构造 ES 客户端
    elasticlient::Client client({"http://127.0.0.1:9200/"});
    // 2. 发起搜索请求
    try {
        cpr::Response resp = client.search("user", "_doc", "{\"query\": { \"match_all\": {} }}");
        // 3. 打印响应状态码和响应正文
        std::cout << resp.status_code << std::endl;
        std::cout << resp.text << std::endl;
    } catch (std::exception &e) {
        std::cout << "请求失败: " << e.what() << std::endl;
        return -1;
    }

    return 0;
}